package com.example.chapter5;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.widget.ListView;

public class MainActivity extends Activity {

	private List<ItemData> itemList;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		this.itemList = new ArrayList<ItemData>();
		
		for (int i = 0; i < 100; i++) {
			ItemData itemData = new ItemData();
			itemData.setTitleText(String.format("Title %d", i));
			itemData.setDescriptionText(String.format("Description %d", i));
			itemData.setImageResourceID(R.drawable.ic_launcher);
			
			itemList.add(itemData);
		}
		
		ListView listView = (ListView) this.findViewById(R.id.listView1);
		SampleAdapter sampleAdapter = new SampleAdapter(this, this.itemList);
		listView.setAdapter(sampleAdapter);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_main, menu);
		return true;
	}

}